package com.yiwenup.leetcode.top_interview_150;

/**
 * 文件描述
 *
 * @Project struct-algorithm
 * @Package com.yiwenup.leetcode.top_interview_150
 * @Author yiwenup
 * @Date 2024-12-18 22:31:07
 * @Description https://leetcode.cn/problems/valid-anagram/description/?envType=study-plan-v2&envId=top-interview-150
 */
public class No0242 {
    public boolean isAnagram(String s, String t) {
        int[] tmp = new int[26];
        for (int i = 0; i < s.length(); i++) {
            tmp[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < t.length(); i++) {
            tmp[t.charAt(i) - 'a']--;
        }
        for (int i = 0; i < 26; i++) {
            if (tmp[i] != 0) {
                return false;
            }
        }
        return true;
    }
}
